# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=openocd-riscv
pkgver=0_git20220616
_commit=6d359afde45dba69d2fc2d6fc3f90e32050f8fbf
pkgrel=0
pkgdesc="Fork of OpenOCD with RISC-V support"
url="https://github.com/riscv/riscv-openocd"
arch="all"
license="GPL-2.0-only,GPL-2.0-or-later,GPL-3.0-only"
depends="!openocd-git !openocd"
makedepends="libftdi1-dev libusb-dev hidapi-dev libtool automake autoconf
	jimtcl-dev libjaylink-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/riscv/riscv-openocd/archive/$_commit.tar.gz
	fix-jimtcl-link.patch"
builddir="$srcdir/riscv-openocd-$_commit"

##
# XXX: Remove this aport when changes are upstreamed.
##

prepare() {
	default_prepare
	./bootstrap nosubmodule
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-werror \
		--disable-internal-jimtcl \
		--disable-internal-libjaylink
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
3d3531a6410fc4fedd4a9a7eace05c6ba6ca7efaa67283ee326a3f6572e714fd04c24a8c88538837be702c21fff61cb8eb1fb35ad96cb3a976b57705f055bee3  openocd-riscv-0_git20220616.tar.gz
6fd2fbe11917bb7f181ba67812f63e75d51bcd19e4df6a7e22e1abb8f36a4f4bdc9202e815f560476ec184d54d84df8ae4dceb17f2429b9dc1d9503804dacb03  fix-jimtcl-link.patch
"
